package com.cxf.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cxf.service.UserService;
import com.cxf.service.impl.UserServiceImpl;

public class Login extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserService usrService = new UserServiceImpl();
		response.setContentType("text/html;charset=UTF-8");
		String userName = request.getParameter("userName");
		String password = request.getParameter("password");
		try {
			usrService.validate(userName, password);
			response.getWriter().append("登录成功");
		} catch (Exception e) {
			response.getWriter().append("登录失败");
		}
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
